package com.he.principles.LSP.after;


/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/8/22 10:52
 */
public class RectangleTest {
    public static void main(String[] args) {
        System.out.println("==============长方形");
        RectangleServiceImpl rectangleServiceImpl = new RectangleServiceImpl();
        rectangleServiceImpl.setLength(20d);
        rectangleServiceImpl.setWidth(10d);
        resize(rectangleServiceImpl);
        printLengthAndWidth(rectangleServiceImpl);

        //正方形：此时没有父子关系了，调用不了resize
    }

    /**
     * @Description 扩宽方法
     * @Author HCL
     * @Date 2024/8/21 17:18
     * @Param []
     * @Return void
     */
    private static void resize(RectangleServiceImpl rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    /**
     * @Description 打印长、宽
     * @Author HCL
     * @Date 2024/8/22 9:45
     * @Param []
     * @Return void
     */
    private static void printLengthAndWidth(QuadrilateralService quadrilateralService){
        System.out.println("length = " + quadrilateralService.getLength());
        System.out.println("width = " + quadrilateralService.getWidth());
    }
}
